# 关闭文件
import os
def close_file():
    file = open('text1', 'a+', encoding='utf-8')
    file.write(f'当前文件所在目录为：{os.path.dirname(__file__)}\n')
    file.seek(0)
    print('读取所有文件内容：', file.read())
    file.close()

if __name__ == '__main__':
    close_file()